<?php

class MuyuZip{
	
public static function compresszip($zipnname,$path){
	$zip = new ZipArchive();
	if ($zip->open($zipnname, ZIPARCHIVE::CREATE) === true) {
		$files = self::listdir($path);
		if($files !== false){
			foreach($files as $p)
			{
			$zip->addFile($p,str_replace("./","",str_replace("\\","/",$p)));
			}
			$zip->close();
			return true;
		}else{
			return false;
		}
	}else{
		return false;
	}
}


public static function listdir($start_dir) {
	$files = array();
	if (is_dir($start_dir)) {
	$fh = opendir($start_dir);
	while (($file = readdir($fh)) !== false) {
	if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
	$filepath = $start_dir . '/' . $file;
	if ( is_dir($filepath) )
	$files = array_merge($files, self::listdir($filepath));
	else
	array_push($files, $filepath);
	}
	closedir($fh);
	} else {
	$files = false;
	}
	return $files;
}

}